﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using DAL = KC.DataAccess.MV;

public partial class Tags : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		DAL.MV8DataContext dc = new DAL.MV8DataContext(ConfigurationManager.ConnectionStrings["MV8"].ConnectionString);

		int TagID = -1;
		if (Request.QueryString["ID"] != null) int.TryParse(Request.QueryString["ID"], out TagID);
		// if (Master.values.ContainsKey("id")) TagID = int.Parse(Master.values["id"]);
		if (TagID >= 0) {
			var posts = from p in dc.Posts
						join tp in dc.TagToPosts
						  on p.ID equals tp.PID
						where tp.TID == TagID
						orderby p.Created descending
						select p;
			rCatDetail.DataSource = posts;
			rCatDetail.DataBind(); }

		var tags = from t in dc.Tags
				   orderby t.Title
				   select t;
		rCats.DataSource = tags;
		rCats.DataBind();
	}
}